﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;

namespace ly.Web.Admin
{
    public partial class activityManager : System.Web.UI.Page
    {
        ly.BLL.Activity actBll = new BLL.Activity();
        ly.Model.Activity actModel = new Model.Activity();
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                BindData();
            }

        }
        //数据绑定方法
        private void BindData()
        {
            
            //string username = "";
            //string strwhere = "where Type in('老师','普通用户' ) username like '%" + username + "%'";
            string strwhere = "";
            DataTable dt = actBll.GetList(strwhere).Tables[0];
            PagedDataSource ps = new PagedDataSource();
            ps.DataSource = dt.DefaultView;
            ps.AllowPaging = true;
            AspNetPager1.RecordCount = dt.Rows.Count;
            ps.CurrentPageIndex = AspNetPager1.CurrentPageIndex - 1;
            ps.PageSize = AspNetPager1.PageSize;
            rptActivity.DataSource = ps;
            rptActivity.DataBind();
        }
        //修改imgbtn按钮
        public void imbtnUpdate_Command(object sender, CommandEventArgs e)
        {
            int id = Convert.ToInt32(e.CommandArgument);
            Response.Redirect(string.Format("EditActivity.aspx?id={0}",id));
        
        }
        //图片按钮删除事件
        public void imbtnDel_Command(object sender, CommandEventArgs e)
        {
            int id = Convert.ToInt32(e.CommandArgument);
            actBll.Delete(id);
            DataSet ds = actBll.GetList("");
            rptActivity.DataSource = ds;
            rptActivity.DataBind();

        }
        //图片按钮审核事件
        public void imbtnCheck_Command(object sender, CommandEventArgs e)
        {
            int id = Convert.ToInt32(e.CommandArgument);
            actModel = actBll.GetModel(id);
            actModel.ActivityVerify = "审核通过";
            actBll.Update(actModel);
            BindData();

        }


    }
}